package com.bridgeintelligent.tag.webserver.system.mapper;

import com.bridgeintelligent.tag.webserver.system.model.NoticeModel;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author：liwei
 * @Date：2023/11/8 15:00
 * @Desc：NoticeMapper
 */
@Mapper
public interface NoticeMapper {
    void add(NoticeModel model);

    @Insert("insert into TAG_SYSTEM_NOTICE_USER(ID,USER_ID,NOTICE_ID)VALUES(#{id},#{uid},#{nid})")
    void addUserNotice(@Param("uid")String uid,@Param("nid")String nid,@Param("id")String id);

    void upd(NoticeModel model);

    @Delete("delete from TAG_SYSTEM_NOTICE where id = #{id}")
    void del(String id);

    @Update("update TAG_SYSTEM_NOTICE set status = #{status} where id = #{id} ")
    void operate(@Param("status")String status,@Param("id")String id);

    @Update("update TAG_SYSTEM_NOTICE set status = '2' ")
    void updAllStatus();

    @Delete("delete from TAG_SYSTEM_NOTICE_USER ")
    void delNoticeUserRela();

    @Delete("delete from TAG_SYSTEM_NOTICE_USER where notice_id = #{id} ")
    void delNoticeUserRelaById(String id);

    NoticeModel findOne(String id);

    List<NoticeModel> list(String title);

    @Select("SELECT ID FROM TAG_SYSTEM_NOTICE " +
            "WHERE STATUS = '1' AND ROWNUM = 1\n" +
            "ORDER BY CREATE_TIME DESC ")
    String findLatestNotice();

    @Select("SELECT ID FROM TAG_SYSTEM_NOTICE_USER WHERE USER_ID = #{uid} AND NOTICE_ID = #{nid}")
    String findExist(@Param("uid")String userId,@Param("nid")String noticeId);
}
